// pages/index/tologin/tologin.js
var openidData
var UserInfodata
var nickname =null
var head =null
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    openidData = wx.getStorageSync('openidData')
  },
  bindGetUserInfo: function (e) {
    var that = this;
    var url = wx.getStorageSync('url') 
    //此处授权得到userInfo
    //接下来写业务代码
    nickname = e.detail.userInfo.nickName
    head = e.detail.userInfo.avatarUrl
    console.log(nickname)
    wx.request({
      url: url+'sharkUser/wxLogin',
      data: {
        "type": 1,
        "seq": 1,
        "sysVer": "0.0.1",
        "sendTime": "2019-07-14",
        "userId": "default",
        "resId": "0000",
        "privId": "0000",
        "platform": 2,
        "token": "",
        "shopId": "",
        "userType": 1,
        "source": 4,
        "content": {
          "openid": openidData,
          "username": nickname,
          "shopId": "02369we92MGpVJ0dS9d928sCe9269wex",
          "image": head
        }
      },
      method: "POST",
      header: {
        "Content-Type": "application/JSON"
      },
      success: function (res) {
        console.log(res)
        var userId = res.data.userId
        wx.setStorageSync('userId', userId) 
        wx.navigateBack({
          delta: 1,
        })
      }
    })
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})